/*
 * @Author: dengyl
 * @Date: 2021-10-22 16:54:01
 * @LastEditTime: 2021-11-23 15:34:08
 * @LastEditors: 詹真琦(legendryztachi@gmail.com)
 * @Description: select组件渲染相关（关联项目和预归档到公用）
 * @FilePath: \code\cwp-front\pc-collaboration\src\plugins\mixins\select.js
 */
export default {
  props: {
    formInfo: {
      type: Object
    }
  },
  data() {
    return {
      hidden: false, // 隐藏
      disabled: false, // 禁用
      className: 'related-project-no-transition',
    };
  },
  components: {
    VNodes: {
      functional: true,
      render: (h, ctx) => ctx.props.vnodes
    }
  },
  methods: {
    selectRender(menu) {
      return (
        <div>
          <v-nodes vnodes={menu} />
          <a-divider style="margin: 4px 0;" />
          <div
            style="padding: 4px 8px; cursor: pointer;"
            onClick={this.showDialog}>
            {$.i18n('cap.template.common.text.pleaseChoose')}
          </div>
        </div>
      );
    }
  },
  render() {
    return (
      <div v-show={!this.hidden}>
        {this.title + '：'}
        <a-select
          style="width: 130px"
          disabled={this.disabled}
          v-model={this.selected}
          onChange={this.onChange}
          dropdownRender={this.selectRender}
          dropdownClassName={this.className}
          >
          {this.list.map((item) => (
            <a-select-option key={item.value} value={item.value}>
              <a-tooltip title={item.name}>{item.name}</a-tooltip>
            </a-select-option>
          ))}
        </a-select>
      </div>
    );
  }
};
